USE fat1_c1203i_s3_g2
go
if object_id('customer_temp') is not null
BEGIN
  drop table customer_temp
END
SELECT * INTO subcrible_temp FROM subcrible
WHILE(SELECT COUNT(*) FROM subcrible_temp) > 0  
BEGIN
	DECLARE
		@dateto datetime,
		@customerId int
		Select top 1 @customerId = customerId , @dateto = dateto from subcrible_temp
		if DATEDIFF(DD,GETDATE(),@dateto) = 0
		Begin
			update customer set status ='normal' where customerId = @customerId
		End
	DELETE TOP (1) PERCENT FROM subcrible_temp 
END
